package com.soc.web.client.api;

import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;


public class Element extends Widget {
	private Options options;
	
	// The display part
	protected Image thumbnail;
	protected String displayText;
	
	protected native void fancybox(com.google.gwt.dom.client.Element element) /*-{
		var optObject = this.@com.soc.web.client.api.Element::options;
		if(optObject != null) {
			var opts = optObject.@com.soc.web.client.api.Options::generate()();
			$wnd.$(element).fancybox(opts);
		} else {
			$wnd.$(element).fancybox();
		}
	}-*/;
	
	protected native void fancyboxRel(String relation) /*-{
		var optObject = this.@com.soc.web.client.api.Element::options;
		if(optObject != null) {
			var opts = optObject.@com.soc.web.client.api.Options::generate()();
			if(opts != null) {
				$wnd.$("a[rel="+relation+"]").fancybox(opts);
			} else {
				$wnd.$("a[rel="+relation+"]").fancybox();
			}
		} else {
			$wnd.$("a[rel="+relation+"]").fancybox();
		}
	}-*/;
	
	protected native void fancybox(String idRef) /*-{
		var optObject = this.@com.soc.web.client.api.Element::options;
		if(optObject != null) {
			var opts = optObject.@com.soc.web.client.api.Options::generate()();
			if(opts != null) {
				$wnd.$(idRef).fancybox(opts);
			} else {
				$wnd.$(idRef).fancybox();
			}
		} else {
			$wnd.$(idRef).fancybox();
		}
	}-*/;
	
	
	/**
	 * Closes fancybox window
	 */
	protected native void close() /*-{
		$wnd.$.fancybox.close();
	}-*/;
	
	/**
	 * Forces a resize of the fancybox
	 */
	protected native void resize() /*-{
		$wnd.$.fancybox.resize();
	}-*/;
	
	/**
	 * Center the fancybox on the screen
	 */
	protected native void center() /*-{
		$wnd.$.fancybox.center();
	}-*/;
	
	/**
	 * Cancel loading data.
	 */
	protected native void cancel() /*-{
		$wnd.$.fancybox.cancel();
	}-*/;
	
	protected static native void pos() /*-{
		$wnd.$.fancybox.pos();
	}-*/;
	
	/**
	 * Move to the previous entry.
	 */
	protected native void prev() /*-{
		$wnd.$.fancybox.prev();
	}-*/;
	
	/**
	 * Move to the next entry.
	 */
	public native void next() /*-{
		$wnd.$.fancybox.next();
	}-*/;
	
	/**
	 * Hide the activity icon
	 */
	public native void hideActivity() /*-{
		$wnd.$.fancybox.hideActivity();
	}-*/;
	
	/**
	 * Show the activity icon.
	 */
	public native void showActivity() /*-{
		$wnd.$.fancybox.showActivity();
	}-*/;
	
	public void setOptions(Options options) {
		this.options = options;
	}
	
	public Options getOptions() {
		return options;
	}
	
	public Image getThumbnail() {
		return thumbnail;
	}

	public void setThumbnail(Image thumbnail) {
		this.thumbnail = thumbnail;
	}
	
	public void setDisplayText(String displayText) {
		this.displayText = displayText;
	}
	
	public String getDisplayText() {
		return displayText;
	}
	
}
